const path = require("path");

const config = {
  projectName: "deerBlock",
  date: "2022-4-17",
  designWidth: 750,
  deviceRatio: {
    640: 2.34 / 2,
    750: 1,
    828: 1.81 / 2
  },
  sourceRoot: "src",
  outputRoot: `dist/${process.env.TARO_ENV}`,
  plugins: [],
  defineConstants: {
    IS_H5: process.env.TARO_ENV === "h5",
    IS_RN: process.env.TARO_ENV === "rn",
    IS_WEAPP: process.env.TARO_ENV === "weapp",
  },
  alias: {
    "@src": path.resolve(__dirname, "..", "src"),
    "@components": path.resolve(__dirname, "..", "src/components"),
    "@utils": path.resolve(__dirname, "..", "src/utils"),
    "@store": path.resolve(__dirname, "..", "src/store"),
    "@reducers": path.resolve(__dirname, "..", "src/reducers"),
    "@bridge": path.resolve(__dirname, "..", "src/bridge"),
    "@hooks": path.resolve(__dirname, "..", "src/hooks"),
    "@assets": path.resolve(__dirname, "..", "src/assets"),
    "@styles": path.resolve(__dirname, "..", "src/styles"),
  },
  copy: {
    patterns: [],
    options: {}
  },
  framework: "react",
  mini: {
    postcss: {
      pxtransform: {
        enable: true,
        config: {}
      },
      url: {
        enable: true,
        config: {
          limit: 1024 // 设定转换尺寸上限
        }
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: "module", // 转换模式，取值为 global/module
          generateScopedName: "[name]__[local]___[hash:base64:5]"
        }
      }
    }
  },
  rn: {
    appName: "deerblock",
    output: {
      ios: "ios/main.jsbundle",
      iosAssetsDest: "ios",
      android: "android/app/src/main/assets/index.android.bundle",
      androidAssetsDest: "android/app/src/main/res"
    },
    postcss: {
      pxtransform: {
        enable: true,
        config: {}
      },
      cssModules: {
        enable: false, // 默认为 false，如需使用 css modules 功能，则设为 true
        config: {
          namingPattern: "module", // 转换模式，取值为 global/module
          generateScopedName: "[name]__[local]___[hash:base64:5]"
        }
      }
    }
  }
};

module.exports = function (merge) {
  if (process.env.NODE_ENV === "development") {
    return merge({}, config, require("./dev"));
  }
  return merge({}, config, require("./prod"));
};
